extends "ChaInfo.gd"

var sk1 = 0
var sk2 = 0
var sk3 = 0

var researchTag = true

func toJson():
	var json = .toJson()
	json["sk1"] = sk1
	json["sk2"] = sk2
	json["sk3"] = sk3
	return json

func extendsEvo(cha):
	.extendsEvo(cha)
	sk1 = cha.sk1
	sk2 = cha.sk2
	sk3 = cha.sk3
	research.rCha = self
	_extInit()

func showChoiceSkill(skLv):
	var skillWindow = utils.createWindowDialog(sys.main.get_node("ui"), "学习技能", Vector2(1150, 350))
	skillWindow.popup_exclusive = true
	skillWindow.get_close_button().hide()

	var context = utils.createGridContainer(skillWindow, 2, Vector2(50, 50))
	var k1 = get("sk%dt1"%[skLv])
	utils.createRichTextLabel(utils.consts.colorRed + "[{1}]:{2}".format({"1":k1[0],"2":k1[1]}), context, Vector2(1000, 100))
	utils.createItemButton(context, self, "学习", "doChoiceSkill", [1, skillWindow, skLv])
	var k2 = get("sk%dt2"%[skLv])
	utils.createRichTextLabel(utils.consts.colorRed + "[{1}]:{2}".format({"1":k2[0],"2":k2[1]}), context, Vector2(1000, 100))
	utils.createItemButton(context, self, "学习", "doChoiceSkill", [2, skillWindow, skLv])

	skillWindow.popup_centered()

func doChoiceSkill(index, skillWindow, skLv):
	# _extInit()
	set("sk%d"%[skLv], index)
	call("doChoiceSkill%d"%[skLv])
	skillWindow.queue_free()

func _onBattleStart():
	._onBattleStart()
	upAtt()

#执行extInit后执行此函数
func postInit():
	if lv == 2:
		attInfox.maxHp *= 1.5
		attInfox.atk *= 1.2
		attInfox.mgiAtk *= 1.2
		attInfox.def += 30
	elif lv == 3:
		attInfox.maxHp *= 2.25
		attInfox.atk *= 1.5
		attInfox.mgiAtk *= 1.5
		attInfox.def += 80
	elif lv == 4:
		attInfox.maxHp *= 3.5
		attInfox.atk *= 2
		attInfox.mgiAtk *= 2
		attInfox.def += 120
	if mainFlag and mainName == "":
		mainDmg = 40
		mainName = "[color=#F8F8FF][默认]152mm连装炮[/color]"
	if torpFlag and torpName == "":
		torpDmg = 100
		torpName = "[color=#F8F8FF][默认]三联装533mm鱼雷[/color]"
		torpCd = 6
	upAtt()	
	if isInManual() and get("upText1") != null:
		showInManual()
	elif upgraded:
		upgrade()
	checkRealLove()	
	fillSkillSlotText()

			